#pragma once

// Dependencies
#include "Point2.h"
#include "Vector2.h"

// Rect2_t
// Represents a rectangle in 2D space
template<class T>
class Rect2_t {
public: // Typedefs
	typedef T value_type;
	typedef Rect2_t<T> this_type;

public: // Constructors
	Rect2_t();
	Rect2_t( T left, T bottom, T right, T top );

public: // Named constructors
	// Construct a rectangle from x and y, and with and height
	static Rect2_t<T> fromSize( T x, T y, T w, T h );
	static Rect2_t<T> fromCenterSize( T x, T y, T w, T h );

public: // Accessors
	// Select a vertex from the Rect2_t, starting with 0=(left,bottom) and traversing counterclockwise to 3=(left, top)
	const Point2_t<T> corner( int idx ) const;
	const Vector2_t<T> extents() const;
	T width() const;
	T height() const;

public: // Members
	T left, bottom, right, top;

private: // Static members
	static T this_type::* const corners[][2];	// List of pointer-to-member-variables that dictate which members of Rect2_t to use for which corner
};

// Global typedefs
typedef Rect2_t<int> Rect2i;
typedef Rect2_t<float> Rect2f;
typedef Rect2_t<double> Rect2;